package cn.tedu.lucky.draw.server.repository;

import cn.tedu.lucky.draw.server.protocol.po.Activity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface ActivityRepository extends JpaRepository<Activity,Long> {

    //根据活动名称和活动状态来进行升序查询
    List<Activity> findByNameAndStatusOrderBySortAsc(String name,Integer status);

    //案例练习 查询ID在29-50之间的活动
    List<Activity> findByIdBetween(Long start,Long end);

    Page<Activity> findActivityByStatusAndEndTimeBefore(Integer status, LocalDateTime currentTime, Pageable pageable);

    List<Activity> findByStatus(Integer status);
}
